<?php
session_start();
if(isset($_SESSION['userid'])&&$_SESSION['level']!=2)
{
	
	header ("location: login.php");
	exit();
}
?>
<?php
include("includes/top_user.php");
?>
<script type="text/javascript" >
function doLink()
{
	window.location="add_type.php";
}
function doLink1()
{
	window.location="add_cate.php";
}
</script>

<div id="box">
<h3>Quản Lý</h3>
<h4>Thể Loại</h4>
<table>
	<thead>
		<tr>
            <th width="100px"><a href="#">Mã Loại<img src="img/icons/arrow_down_mini.gif" width="16" height="16" align="absmiddle" /></a></th>
            <th><a href="#">Tên Loại</a></th>
            <th><a href="#">Thực Thi</a></th>
            
            
         </tr>
     </thead>
     <tbody>
         <?php
		 include("includes/connect.php");
		 $sql="select * from type_category order by maloai";
		 mysql_query("set names 'utf8'");
		 $query=mysql_query($sql);
		 
		 if(mysql_num_rows($query) == "")
		 {
			 echo "<tr><td colspan=5 align=center>Chưa có username nào</td></tr>";
		}
		else
		{
			
			while($row=mysql_fetch_array($query))
			{
			echo "<tr>";
			echo "<td>$row[maloai]</td>";
			echo "<td>$row[tenloai]</td>";
			echo "<td><a href=show_type.php?typeid=$row[maloai]><img src=img/icons/user.png title=Xem width=16 height=16 /></a><a href=edit_type.php?typeid=$row[maloai]><img src=img/icons/user_edit.png title=Sửa width=16 height=16 /></a><a href=del_type.php?typeid=$row[maloai]><img src=img/icons/user_delete.png title=Xóa width=16 height=16 /></a></td>";
			echo "</tr>";
			}
		}
	
		 ?>
     
	<tr>
    <td colspan="2">&nbsp;</td><td><input type="button" value="Thêm thể loại mới" onclick="doLink();"  /></td>
    </tr>
	</tbody>
</table>
<h4>Danh Mục</h4>
<table>
	<thead>
		<tr>
            <th width="100px"><a href="#">Mã Danh Mục<img src="img/icons/arrow_down_mini.gif" width="16" height="16" align="absmiddle" /></a></th>
            <th><a href="#">Tên Danh Mục</a></th>
            <th><a href="#">Thuộc Loại</a></th>
            <th><a href="#">Thực Thi</a></th>  
         </tr>
     </thead>
     <tbody>
         <?php
		 include("includes/connect.php");
		 $sql_cate="select category.id,category.cate_name,category.maloai, type_category.tenloai
		 		  from category, type_category
				  where category.maloai = type_category.maloai
				  order by id";
		 mysql_query("set names 'utf8'");
		 $query_cate=mysql_query($sql_cate);
		 
		 if(mysql_num_rows($query_cate) == "")
		 {
			 echo "<tr><td colspan=5 align=center>Chưa có username nào</td></tr>";
		}
		else
		{
			
			while($row_cate=mysql_fetch_array($query_cate))
			{
			echo "<tr>";
			echo "<td>$row_cate[id]</td>";
			echo "<td>$row_cate[cate_name]</td>";
			echo "<td>$row_cate[tenloai]</td>";
			echo "<td><a href=show_cate.php?cateid=$row_cate[id]><img src=img/icons/user.png title=Xem width=16 height=16 /></a><a href=edit_cate.php?cateid=$row_cate[id]><img src=img/icons/user_edit.png title=Sửa width=16 height=16 /></a><a href=del_cate.php?cateid=$row_cate[id]><img src=img/icons/user_delete.png title=Xóa width=16 height=16 /></a></td>";
			echo "</tr>";
			}
		}
	
		 ?>
     
	<tr>
    <td colspan="2">&nbsp;</td><td><input type="button" value="Thêm danh mục mới" onclick="doLink1();"  /></td>
    </tr>
	</tbody>
</table>
</div>

<?php
include("includes/sidebar.php");
?>

<?php
include("includes/footer.php");
?>